﻿<Window x:Class="SampleInputResultsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:RegexUtility"
        xmlns:regex="clr-namespace:System.Text.RegularExpressions;assembly=System"
        Title="Sample Input Results"
        Height="350"
        Width="525"
        DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}">
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <TextBox Text="{Binding RegexPattern}"
                 IsReadOnly="True"
                 Margin="4,2" />

        <TextBox x:Name="SampleInputTextBox"
                 Text="{Binding SampleInput}"
                 Grid.Row="1"
                 IsReadOnly="True"
                 Margin="4,2"
                 Height="60"
                 HorizontalScrollBarVisibility="Auto"
                 VerticalScrollBarVisibility="Auto"
                 FocusManager.IsFocusScope="True" />

        <TreeView ItemsSource="{Binding Matches}"
                  Grid.Row="2"
                  Margin="4"
                  SelectedItemChanged="MatchesTreeView_SelectedItemChanged">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Details}">

                    <StackPanel>
                        <TextBlock Text="Match" />
                        <TextBlock Text="{Binding Success}" />
                        <TextBox Text="{Binding Value}"
                                 IsReadOnly="True" />
                    </StackPanel>

                    <HierarchicalDataTemplate.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding Items}">
                            <TextBlock Text="{Binding Title}" />

                            <HierarchicalDataTemplate.Resources>

                                <DataTemplate DataType="{x:Type regex:Capture}">
                                    <TextBlock Text="Capture" />
                                </DataTemplate>

                                <DataTemplate DataType="{x:Type regex:Group}">
                                    <TextBlock Text="Group" />
                                </DataTemplate>

                            </HierarchicalDataTemplate.Resources>
                        </HierarchicalDataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>

                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>

    </Grid>
</Window>
